import { postAdd, getList } from '@/services'

const state = {
    addressList:[]
};

const mutations = {
    updata(state,payload){
        for(let key in payload){
            state[key]=payload[key]
        }
    }
};

const actions = {
    async postAdd({ commit }, payload) {
       await postAdd(payload);
        const result = await getList()
        console.log(result);
        if(result.status===401)return
        commit('updata',{addressList:result})
    },
    async getList({ commit }) {
        const result = await getList()
        if(result.status===401)return
        commit('updata',{addressList:result})
        console.log(result);
    }
};

export default {
    namespaced: true,
    state,
    mutations,
    actions,
};
